package com.easy.venue.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.easy.common.bean.SeatPriceBean;
import com.easy.common.service.ISeatPriceService;
import com.easy.venue.mapper.SeatPriceMapper;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
@DubboService // dubbo服务
public class SeatPriceServiceImpl extends ServiceImpl<SeatPriceMapper, SeatPriceBean> implements ISeatPriceService {
    @Override
    public SeatPriceBean getSeatPriceById(Integer id) {
        return super.getById(id);
    }

    @Override
    public SeatPriceBean getSeatPriceBySeatId(Integer seatId) {
        LambdaQueryWrapper<SeatPriceBean> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(SeatPriceBean::getSeatid,seatId);
        return super.getOne(queryWrapper);
    }

    @Override
    public Integer addSeatPrice(SeatPriceBean seatPriceBean) {
        if(super.save(seatPriceBean))
            return 1;
        else
            return 0;
    }

    @Override
    public Integer updateSeatPrice(SeatPriceBean seatPriceBean) {
        return super.updateById(seatPriceBean)?1:0;
    }

    @Override
    public Integer deleteSeatPrice(Integer id) {
        return super.removeById(id)?1:0;
    }

    @Override
    public List<SeatPriceBean> getAll(SeatPriceBean seatPriceBean) {
        LambdaQueryWrapper<SeatPriceBean> queryWrapper = new LambdaQueryWrapper<>();
        return super.list(queryWrapper);
    }

    @Override
    public IPage<SeatPriceBean> getPage(SeatPriceBean seatPrice, Page<SeatPriceBean> page) {
        LambdaQueryWrapper<SeatPriceBean> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.like(SeatPriceBean::getSeatid,seatPrice.getSeatid());
        return super.page(page);
    }
}
